<!-- ====================================================== -->
<!-- Adempiere Distribution Setup                            -->
<!-- ====================================================== -->
<!-- $Header: /cvs/adempiere/install/Adempiere/build.xml,v 1.4 2006/07/03 16:51:31 jjanke Exp $-->

<project name="setup" default="setup" basedir=".">

	<description>
	This buildfile is used to setup the Adempiere Environment.
	</description>

	<property environment="env" />
	<property name="envFile" value="AdempiereEnv.properties" />
 	<property name="server" value="nas" />

	<patternset id="manifest.exclude">
	  <exclude name="META-INF/*.DSA"/>
	  <exclude name="META-INF/*.RSA"/>
	  <exclude name="META-INF/*.SF"/>
	  <exclude name="META-INF/MANIFEST.MF"/>
	  <exclude name="META-INF/INDEX.LIST"/>
	</patternset>

	<!-- ==================================================== -->
	<!-- Init                                                 -->
	<!-- ==================================================== -->
	<target name="setupInit"
		description="initialization target">

		<echo message="Adempiere Server Setup ===================" />
		<echo message="ADEMPIERE_HOME = ${env.ADEMPIERE_HOME}" />

		<!-- create the time stamp and environment -->
		<tstamp />
		<available file="${envFile}" property="envFileExists" />
		<available file="lib/AdempiereOriginal.jar" type="file" property="adempiereOriginal.exists"/>
		<available file="lib/webuiOriginal.war" type="file" property="webuiOriginal.exists"/>
		<fail message="**** RUN_setup was not successful - please re-run ****" unless="envFileExists" />
		<property file="${envFile}"/>
		<filter filtersfile="${envFile}" />

		<echo message="Environment   = ${envFile}" />
		<echo message="Java VM       = ${ADEMPIERE_JAVA_TYPE}" />
		<echo message="Database      = ${ADEMPIERE_DB_TYPE}" />
		<echo message="Apps Server   = ${ADEMPIERE_APPS_TYPE}" />
		<echo message="AppsDeployment= ${ADEMPIERE_APPS_DEPLOY}" />


		<!-- Environment variables -->
		<condition property="isWindows">
			<os family="windows" />
		</condition>
		<condition property="isAppsJBoss">
			<equals arg1="jboss" arg2="${ADEMPIERE_APPS_TYPE}" />
		</condition>
		<condition property="isAppsGlassfish">
			<equals arg1="glassfish" arg2="${ADEMPIERE_APPS_TYPE}" />
		</condition>
		<echo message="Windows=${isWindows} JBoss=${isAppsJBoss} Glassfish=${isAppsGlassfish}" />

	</target>

	<!-- ==================================================== -->
	<!-- Windows Setup                                        -->
	<!-- ==================================================== -->
	<target name="setupWin" depends="setupInit" if="isWindows"
		description="Windows Setup">

		<!--	Filter files No Overwrite	-->
		<copy file="utils/myDBcopyTemplate.bat"
			tofile="utils/myDBcopy.bat" filtering="yes" overwrite="no" />

		<!--	Filter files Overwrite		-->
		<copy file="utils/myEnvironmentTemplate.bat"
			tofile="utils/myEnvironment.bat" filtering="yes" overwrite="yes" />

		<copy file="utils/RUN_GetAdempiereTemplate.bat"
			tofile="utils/RUN_GetAdempiere.bat" filtering="yes" overwrite="yes" />
		<copy file="utils/RUN_PutExportTemplate.bat"
			tofile="utils/RUN_PutExport.bat" filtering="yes" overwrite="yes" />
		<copy file="utils/RUN_WinEnvTemplate.bat"
			tofile="utils/RUN_WinEnv.bat" filtering="yes" overwrite="yes" />

		<delete>
			<fileset dir="." includes="**/*.sh" excludes="RUN_Adempiere.sh" />
		</delete>

	</target>


	<!-- ==================================================== -->
	<!-- Non Windows Setup                                    -->
	<!-- ==================================================== -->
	<target name="setupNonWin" depends="setupInit" unless="isWindows"
		description="Non Windows Setup">

		<!--	Filter files No Overwrite	-->
		<copy file="utils/myDBcopyTemplate.sh"
			tofile="utils/myDBcopy.sh" filtering="yes" overwrite="no" />

		<!--	Filter files Overwrite		-->
		<copy file="utils/myEnvironmentTemplate.sh"
			tofile="utils/myEnvironment.sh" filtering="yes" overwrite="yes" />

		<copy file="utils/RUN_GetAdempiereTemplate.sh"
			tofile="utils/RUN_GetAdempiere.sh" filtering="yes" overwrite="yes" />
		<copy file="utils/RUN_PutExportTemplate.sh"
			tofile="utils/RUN_PutExport.sh" filtering="yes" overwrite="yes" />
		<copy file="utils/RUN_UnixEnvTemplate.sh"
			tofile="utils/RUN_UnixEnv.sh" filtering="yes" overwrite="yes" />

		<!--	Fix OS stuff	-->
		<fixcrlf srcdir="." eol="lf" eof="remove" includes="**/*.sh" />
		<chmod dir="." perm="ugo+x" includes="**/*.sh" />

		<delete>
			<fileset dir="." includes="*.bat" excludes="RUN_Adempiere.bat" />
			<fileset dir="utils" includes="**/*.bat" />
		</delete>

	</target>

	<target name="backupAdempiereOriginal" unless="adempiereOriginal.exists">
		<copy file="lib/Adempiere.jar" tofile="lib/AdempiereOriginal.jar" overwrite="yes" />
	</target>
	<target name="backupWebuiOriginal" unless="webuiOriginal.exists">
		<copy file="lib/webui.war" tofile="lib/webuiOriginal.war" overwrite="yes" />
	</target>

	<!-- rebuild Adempiere.jar and webui.war to include possible customization and patches -->
	<target name="setupALib" depends="setupInit, backupAdempiereOriginal">
		<delete file="lib/packages.jar" failonerror="false"/>
		<jar jarfile="lib/packages.jar" duplicate="preserve">
			<!-- 2pack packages -->
			<zipgroupfileset dir="packages" includes="**/lib/*.jar" casesensitive="no">
				<patternset refid="manifest.exclude"/>
			</zipgroupfileset>
		</jar>
		<jar jarfile="lib/Adempiere1.jar" index="yes" duplicate="preserve">
			<!-- pack patches.jar and customization.jar into Adempiere.jar -->
			<zipfileset src="lib/customization.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<!-- 2pack packages -->
			<zipfileset src="lib/packages.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/patches.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<!-- posterita packages -->
			<zipfileset src="lib/posterita.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/AdempiereOriginal.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<indexjars>
				<pathelement path="lib/AdempiereCLib.jar"/>
				<pathelement path="lib/CompiereJasperReqs.jar"/>
			</indexjars>
			<manifest>
	        	<attribute name="Specification-Title" value="Adempiere"/>
		        <attribute name="Specification-Version" value="${ADEMPIERE_VERSION}"/>
		        <attribute name="Specification-Vendor" value="ADempiere"/>
		        <attribute name="Implementation-Title" value="Adempiere ${ADEMPIERE_VERSION}"/>
		        <attribute name="Implementation-Version" value="${ADEMPIERE_VERSION} ${DSTAMP}-${TSTAMP}"/>
		        <attribute name="Implementation-Vendor" value="${ADEMPIERE_VENDOR}"/>
		        <attribute name="Implementation-URL" value="http://www.adempiere.com"/>
		        <attribute name="Main-Class" value="org.compiere.Adempiere"/>
		        <attribute name="Class-Path" value="AdempiereSLib.jar"/>
    		</manifest>
	    </jar>

		<!-- Sign Adempiere Jar -->
		<signjar jar="lib/Adempiere1.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<copy file="lib/Adempiere1.jar" tofile="lib/Adempiere.jar" overwrite="yes" />

		<!-- Sign patches Jar -->
		<copy file="lib/patches.jar" tofile="lib/patches1.jar" overwrite="yes" />
		<signjar jar="lib/patches1.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<copy file="lib/patches1.jar" tofile="lib/patches.jar" overwrite="yes" />

		<!-- Sign customization Jar -->
		<copy file="lib/customization.jar" tofile="lib/customization1.jar" overwrite="yes" />
		<signjar jar="lib/customization1.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<copy file="lib/customization1.jar" tofile="lib/customization.jar" overwrite="yes" />

		<!-- clean up -->
		<delete  file="lib/Adempiere1.jar"/>
		<delete  file="lib/patches1.jar"/>
		<delete  file="lib/customization1.jar"/>
	</target>

	<!-- rebuild Adempiere.jar and webui.war to include possible customization and patches -->
	<target name="setupWLib" depends="setupInit, backupWebuiOriginal">
		<delete file="lib/zkpackages.jar" failonerror="false"/>
		<jar jarfile="lib/zkpackages.jar" duplicate="preserve">
			<!-- 2pack zkpackages -->
			<zipgroupfileset dir="zkpackages" includes="**/lib/*.jar" casesensitive="no">
				<patternset refid="manifest.exclude"/>
			</zipgroupfileset>
		</jar>
		<zip destfile="lib/webui1.war" duplicate="preserve">
			<!-- pack zkpatches.jar and zkcustomization.jar into webui.war -->
			<zipfileset src="lib/zkcustomization.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<!-- 2pack zkpackages -->
			<zipfileset src="lib/zkpackages.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/zkpatches.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/webuiOriginal.war" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
	    </zip>

		<copy file="lib/webui1.war" tofile="lib/webui.war" overwrite="yes" />
		<!-- clean up -->
		<delete  file="lib/webui1.war"/>
	</target>

	<!-- ==================================================== -->
	<!-- Adempiere Client Lib                                  -->
	<!-- ==================================================== -->
	<target name="setupCLib" depends="setupInit"
		description="Setup Adempiere Client Lib">

		<!-- Delete Old		-->
		<delete file="lib/AdempiereCLib.jar" failonerror="no" />
		<delete file="lib/CClient.jar" failonerror="no" />
		<delete file="lib/CTools.jar" failonerror="no" />

		<!-- Create AdempiereCLib.jar file 	-->
		<jar jarfile="lib/AdempiereCLib.jar" index="yes" duplicate="preserve">
			<zipfileset src="lib/${ADEMPIERE_APPS_TYPE}.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/CCTools.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/oracle.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/postgresql.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>

			<manifest>
				<attribute name="Specification-Title" value="Adempiere Client Library" />
				<attribute name="Specification-Version" value="${ADEMPIERE_MAIN_VERSION}" />
				<attribute name="Specification-Vendor" value="Adempiere" />
				<attribute name="Implementation-Title" value="AdempiereCLib ${ADEMPIERE_MAIN_VERSION}" />
				<attribute name="Implementation-Version" value="${ADEMPIERE_MAIN_VERSION} ${DSTAMP}-${TSTAMP}" />
				<attribute name="Implementation-Vendor" value="Adempiere, Inc." />
				<attribute name="Implementation-URL" value="http://www.adempiere.com" />
			</manifest>
		</jar>

		<echo message="KeyStore=${ADEMPIERE_KEYSTORE} - Alias=${ADEMPIERE_KEYSTORECODEALIAS}" />
		<!-- Sign AdempiereCLib Jar 		-->
		<signjar jar="lib/AdempiereCLib.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />

	</target>

	<!-- ==================================================== -->
	<!-- Adempiere Server Lib                                  -->
	<!-- ==================================================== -->
	<target name="setupSLib" depends="setupInit"
		description="Setup Adempiere Server Lib">

		<!-- Delete Old		-->
		<delete file="lib/AdempiereSLib.jar" failonerror="no" />
		<delete file="lib/CServer.jar" failonerror="no" />

		<!-- Create AdempiereSLib.jar file 	-->
		<jar jarfile="lib/AdempiereSLib.jar" index="yes" duplicate="preserve">
			<zipfileset src="lib/CSTools.jar">
				<patternset refid="manifest.exclude"/>
				<exclude name="**/*.bsh"/>
			</zipfileset>
			<zipfileset src="lib/oracle.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/postgresql.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<zipfileset src="lib/CompiereJasperReqs.jar" >
				<patternset refid="manifest.exclude"/>
			</zipfileset>
			<manifest>
				<attribute name="Specification-Title" value="Adempiere Server Library" />
				<attribute name="Specification-Version" value="${ADEMPIERE_MAIN_VERSION}" />
				<attribute name="Specification-Vendor" value="Adempiere" />
				<attribute name="Implementation-Title" value="AdempiereSLib ${ADEMPIERE_MAIN_VERSION}" />
				<attribute name="Implementation-Version" value="${ADEMPIERE_MAIN_VERSION} ${DSTAMP}-${TSTAMP}" />
				<attribute name="Implementation-Vendor" value="Adempiere, Inc." />
				<attribute name="Implementation-URL" value="http://www.adempiere.com" />
			</manifest>
		</jar>

		<!-- Sign AdempiereSLib Jar 		-->
		<signjar jar="lib/AdempiereSLib.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<delete dir="buildSLib" />

		<!-- Sign CompiereJasperReqs.jar for Java Web Start	-->
		<signjar jar="lib/CompiereJasperReqs.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
		   	storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />

	</target>

	<!-- Sign other application jars -->
	<target name="signOtherJars" depends="setupInit" >
		<!-- Sign AdempiereRoot Jar 		-->
		<copy file="lib/adempiereRoot.jar" tofile="lib/adempiereRoot1.jar" overwrite="yes" />
		<signjar jar="lib/adempiereRoot1.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<copy file="lib/adempiereRoot1.jar" tofile="lib/adempiereRoot.jar" overwrite="yes" />
		<delete file="lib/adempiereRoot1.jar"/>

		<!-- Sign AdempiereApps Jar 		-->
		<copy file="lib/adempiereApps.jar" tofile="lib/adempiereApps1.jar" overwrite="yes" />
		<signjar jar="lib/adempiereApps1.jar" alias="${ADEMPIERE_KEYSTORECODEALIAS}"
			storepass="${ADEMPIERE_KEYSTOREPASS}" keystore="${ADEMPIERE_KEYSTORE}" />
		<copy file="lib/adempiereApps1.jar" tofile="lib/adempiereApps.jar" overwrite="yes" />
		<delete file="lib/adempiereApps1.jar"/>
	</target>


	<!-- ==================================================== -->
	<!-- Setup Lib                                            -->
	<!-- ==================================================== -->
	<target name="setupLib" depends="setupInit, setupWin, setupNonWin, setupCLib, setupSLib, setupALib, setupWLib, signOtherJars"
		description="Setup Adempiere Lib directory">

		<!--	Filter files Overwrite			-->
		<copy file="${basedir}/utils/ftpPutExportTemplate.txt"
			tofile="${basedir}/utils/ftpPutExport.txt" filtering="yes" overwrite="yes" />
		<copy file="${basedir}/utils/ftpGetAdempiereTemplate.txt"
			tofile="${basedir}/utils/ftpGetAdempiere.txt" filtering="yes" overwrite="yes" />
		<copy file="${basedir}/utils/adempiereDirectTemplate.jnlp"
			tofile="${basedir}/lib/adempiereDirect.jnlp" filtering="yes" overwrite="yes" />

		<!--	Create Client Zip		-->
		<zip zipfile="${basedir}/lib/AdempiereClient.zip">
			<zipfileset dir="." prefix="Adempiere"
				includes="*.html" />
			<zipfileset dir="." prefix="Adempiere"
				includes="RUN_Adempiere.*" />
			<zipfileset dir="utils" prefix="Adempiere"
				includes="WinEnv.js" />
			<zipfileset dir="lib" prefix="Adempiere/lib"
				includes="Adempiere.exe,*.ico,customization.jar,patches.jar,CompiereJasperReqs.jar,Adempiere.jar,AdempiereCLib.jar,adempiereDirect.jnlp,index.html,*.0" />
		</zip>

		<!--	Save properties		-->
		<copy file="AdempiereEnv.properties"
			tofile="AdempiereEnv.properties.save" />
		<copy file="Adempiere.properties"
			tofile="Adempiere.properties.save" />
	</target>

	<!-- Update application library -->
	<target name="updateLib" depends="setupInit, setupWin, setupNonWin, setupALib, setupWLib, signOtherJars">
		<!--	Create Client Zip		-->
		<zip zipfile="${basedir}/lib/AdempiereClient.zip">
			<zipfileset dir="." prefix="Adempiere"
				includes="*.html" />
			<zipfileset dir="." prefix="Adempiere"
				includes="RUN_Adempiere.*" />
			<zipfileset dir="utils" prefix="Adempiere"
				includes="WinEnv.js" />
			<zipfileset dir="lib" prefix="Adempiere/lib"
				includes="Adempiere.exe,*.ico,customization.jar,patches.jar,CompiereJasperReqs.jar,Adempiere.jar,AdempiereCLib.jar,adempiereDirect.jnlp,index.html,*.0" />
		</zip>
	</target>

	<target name="createEAR">
		<!-- Create adempiereRoot war		-->
		<zip destfile="${basedir}/lib/adempiereRoot.war">
			<!-- copy Base	-->
			<zipfileset src="${basedir}/lib/adempiereRootBase.war" />
			<!-- copy to adempiereHome	-->
			<zipfileset dir="${basedir}/lib"
				includes="AdempiereClient.zip,Adempiere.jar,AdempiereCLib.jar,*.jnlp,*.0,*.html,CompiereJasperReqs.jar,CompiereJasper.jar"
				prefix="adempiereHome" />
		</zip>

		<!-- Create adempiereWebCM war		-->
		<zip destfile="${basedir}/lib/adempiereWebCM.war">
			<!-- copy Base	-->
			<zipfileset src="${basedir}/lib/adempiereWebCMbase.war" />
		</zip>

		<antcall target="jbossEAR" inheritall="true"/>
		<antcall target="glassfishEAR" inheritall="true"/>
	</target>

	<target name="jbossEAR" if="isAppsJBoss">
		<!-- bundle everything in one ear file for simpler deployment -->
		<ear destfile="${basedir}/lib/adempiere.ear" appxml="${basedir}/lib/adempiereAll.xml" >
			<fileset dir="${basedir}/lib"
				includes="Adempiere.jar,AdempiereSLib.jar,adempiereRoot.jar,adempiereApps.jar,adempiereApps.war,adempiereRoot.war,adempiereWebStore.war,adempiereWebCM.war,posterita.war,posterita.jar,webui.war" />
		</ear>
	</target>

	<target name="glassfishEAR" if="isAppsGlassfish">

		<unzip src="${basedir}/lib/webui.war" dest="${basedir}/lib/webui"/>
		<copy file="${basedir}/lib/webui/WEB-INF/web-2.5.xml" tofile="${basedir}/lib/webui/WEB-INF/web.xml" overwrite="true" />
		<delete file="${basedir}/lib/webui.war"/>
		<zip destfile="${basedir}/lib/webui.war" basedir="${basedir}/lib/webui" />
		<delete dir="${basedir}/lib/webui"/>

		<!-- bundle everything in one ear file for simpler deployment -->
		<ear destfile="${basedir}/lib/adempiere.ear" appxml="${basedir}/lib/adempiereAll.xml" >
			<fileset dir="${basedir}/lib"
				includes="adempiereRoot.jar,adempiereApps.jar,adempiereApps.war,adempiereRoot.war,adempiereWebStore.war,adempiereWebCM.war,posterita.war,posterita.jar,webui.war" />
			<metainf dir="${basedir}/glassfish" includes="sun-application.xml"/>
		</ear>
	</target>

	<!-- ==================================================== -->
	<!-- Setup EAR Libraries                                  -->
	<!-- ==================================================== -->
	<target name="setupEAR" depends="setupLib"
		description="Setup Adempiere EAR Libraries">

		<antcall target="createEAR" inheritall="true"/>
	</target>

	<target name="updateEAR" depends="updateLib">
		<antcall target="createEAR" inheritall="true"/>
	</target>

	<!-- Update JBoss Server -->
	<target name="updateJBoss" depends="updateEAR" if="isAppsJBoss"
		description="Update JBoss Application Server">

		<!-- Copy			-->
		<echo message="AppsDeployment= ${ADEMPIERE_APPS_DEPLOY}" />
		<!-- Deploy in exploded format for faster startup time -->
		<unjar dest="${ADEMPIERE_APPS_DEPLOY}/adempiere.ear" src="${basedir}/lib/adempiere.ear" overwrite="true">
		</unjar>
	</target>

    <!-- ==================================================== -->
	<!-- Setup Glassfish (Sun Application Server)             -->
	<!-- ==================================================== -->
	<target name="setupGlassfish" depends="setupLib, setupEAR" if="isAppsGlassfish"
		description="Setup Glassfish Application Server">
		<copy file="${basedir}/lib/adempiere.ear" tofile="${basedir}/glassfish/adempiere.ear"/>
		<copy file="${basedir}/lib/Adempiere.jar" tofile="${basedir}/glassfish/Adempiere.jar"/>
		<copy file="${basedir}/lib/AdempiereSLib.jar" tofile="${basedir}/glassfish/AdempiereSLib.jar"/>
	</target>

	<!-- ==================================================== -->
	<!-- Setup JBoss Server                                   -->
	<!-- ==================================================== -->
	<target name="setupJBoss" depends="setupEAR" if="isAppsJBoss"
		description="Setup JBoss Application Server">

		<!-- Filter JBoss Templates Conf	-->
		<copy file="${basedir}/jboss/server/adempiere/conf/jboss-serviceTemplate.xml" tofile="${basedir}/jboss/server/adempiere/conf/jboss-service.xml" filtering="yes" overwrite="yes" />
		<copy file="${basedir}/jboss/server/adempiere/conf/login-configTemplate.xml" tofile="${basedir}/jboss/server/adempiere/conf/login-config.xml" filtering="yes" overwrite="yes" />

		<!-- Filter Tomcat 6.0 				-->
		<copy file="${basedir}/jboss/server/adempiere/deploy/jboss-web.deployer/serverTemplate.xml" tofile="${basedir}/jboss/server/adempiere/deploy/jboss-web.deployer/server.xml" filtering="yes" overwrite="yes" />

		<!-- Delete Old		-->
		<delete file="${basedir}/jboss/server/adempiere/lib/CClient.jar" failonerror="no" />
		<delete file="${basedir}/jboss/server/adempiere/lib/CSTools.jar" failonerror="no" />
		<delete file="${basedir}/jboss/server/adempiere/lib/CServer.jar" failonerror="no" />
		<delete file="${basedir}/jboss/server/adempiere/lib/oracle.jar" failonerror="no" />

		<!-- Copy			-->
		<echo message="AppsDeployment= ${ADEMPIERE_APPS_DEPLOY}" />
		<!-- Deploy in exploded format for faster startup time -->
		<unjar dest="${ADEMPIERE_APPS_DEPLOY}/adempiere.ear" src="${basedir}/lib/adempiere.ear" overwrite="true">
		</unjar>
	</target>


	<!-- ==================================================== -->
	<!-- Update J2EE Server                                   -->
	<!-- ==================================================== -->
	<target name="updateDeploy" depends="updateJBoss"
		description="Update Adempiere Application Server">
		<echo message="AppsDeployment= ${ADEMPIERE_APPS_DEPLOY}" />
	</target>

	<!-- ==================================================== -->
	<!-- Deploy J2EE Server                                   -->
	<!-- ==================================================== -->
	<target name="setupDeploy" depends="setupJBoss, setupGlassfish"
		description="Deploy Adempiere Application Server">
		<echo message="AppsDeployment= ${ADEMPIERE_APPS_DEPLOY}" />
	</target>

	<!-- ==================================================== -->
	<!-- Update (Main)                                         -->
	<!-- ==================================================== -->
	<target name="update" depends="updateDeploy"
		description="Update Adempiere Deployment">
	</target>

	<!-- ==================================================== -->
	<!-- Setup (Main)                                         -->
	<!-- ==================================================== -->
	<target name="setup" depends="setupDeploy"
		description="Setup Adempiere">
	</target>


	<!-- ==================================================== -->
	<!-- Test - Copy                                          -->
	<!-- ==================================================== -->
	<target name="testsystemCopy"
		description="Copy Adempiere to Test System">

		<delete dir="lib" />
		<delete dir="jboss" />
		<delete dir="log" />
		<unzip src="\\\\Dev1\\Adempiere\\Install\\Adempiere_253d.zip"
			overwrite="true" />
	</target>

	<!-- ==================================================== -->
	<!-- Test - Import DB                                     -->
	<!-- ==================================================== -->
	<target name="testsystemImport" depends="setup"
		description="Import Adempiere DB">

		<exec command="${basedir}/lib/RUN_AdempiereImport" />
	</target>

	<!-- ==================================================== -->
	<!-- Test - Setup                                         -->
	<!-- ==================================================== -->
	<target name="testsystemSetup" depends="testsystemCopy, testsystemImport"
		description="Set up Test System">

	</target>

	<!-- ==================================================== -->
	<!-- Shutting down server, setting up adempiere and importing database -->
	<!-- ==================================================== -->
	<target name="cleanall" description="shutdown,settingup and importing database">

		<echo message="================Adempiere Server Shutdown ===================" />
		<echo message="OS      = ${os.name}" />

		<!-- Shutting down server by calling the RUN_Stop.bat  or RUN_Stop.sh script in Adempiere dir	-->
		<exec dir="${env.ADEMPIERE_HOME}\utils" executable="cmd" os="Windows XP, Windows 2000, Windows NT" >
		  <arg line="/c RUN_Stop.bat"/>
		</exec>

		<exec dir="${env.ADEMPIERE_HOME}\utils" executable="/bin/sh" os="SunOS,unix">
		  <arg value="-c" />
		  <arg value="RUN_Stop.sh" />
		</exec>

		<echo message="================Adempiere Server Shutdown Complete===================" />
		<sleep seconds="2"/>
		<!-- Deleting all the log files, jboss dir and log dir in ${env.ADEMPIERE_HOME} directory -->
		<delete>
			<fileset dir="${env.ADEMPIERE_HOME}" includes="*.log" />
		</delete>
		<delete dir="${env.ADEMPIERE_HOME}\jboss" />
		<delete dir="${env.ADEMPIERE_HOME}\log" />

		<echo message="=========== ftp to nas and download the current build==============="/>
		<ftp action= "get"
			server="${server}"
			userid="guest"
			password="">
			<fileset  dir="${env.ADEMPIERE_HOME}">
				<include name="**/Adempiere_253d.zip"/>
			</fileset>
		</ftp>

		<!-- unzip and overwrite them and delete the downloaded directory -->
		<unzip src="${env.ADEMPIERE_HOME}/Disk 1/Adempiere_253a.zip" dest="${env.ADEMPIERE_HOME}\..\"  overwrite="yes" />
		<delete dir="${env.ADEMPIERE_HOME}/Disk 1"/>

		<echo message="======================Setup adempiere==============================" />
		<ant inheritAll="false" dir="${env.ADEMPIERE_HOME}" target="setup"/>

		<!-- Importing the database -->
		<exec dir="${env.ADEMPIERE_HOME}\utils" executable="cmd" os="Windows XP, Windows 2000, Windows NT" >
		  <arg line="/c  RUN_ImportAdempiere.bat"/>
		</exec>
		<exec dir="${env.ADEMPIERE_HOME}\utils" executable="/bin/sh" os="SunOS,unix">
		  <arg value="-c" />
		  <arg value="RUN_ImportAdempiere.sh" />
		</exec>

	</target>

</project>